package com.lsa.letcode.the151.reverseWordsInStr;

import static org.junit.Assert.*;

import org.junit.Test;

import com.lsa.letcode.common.LetCodeTestBase;

public class ReverseWordsInStrTest extends LetCodeTestBase {
	@Test
	public void test() throws Exception {
		assertEquals("54321", Solution.reverse(new StringBuilder("12345"), 0, 4)+"");
		assertEquals("15432", Solution.reverse(new StringBuilder("12345"), 1, 4)+"");
		assertEquals("14325", Solution.reverse(new StringBuilder("12345"), 1, 3)+"");
		assertEquals("13245", Solution.reverse(new StringBuilder("12345"), 1, 2)+"");
		
		assertEquals("blue is the sky", Solution.normalize("  blue   is the sky  "));
		assertEquals("blue is the sky", Solution.normalize("blue is the sky"));
		assertEquals("blue is the sky", Solution.normalize("blue is the sky "));
		assertEquals("blue is the sky", Solution.normalize(" blue is the sky"));
		assertEquals("blue is the sky", Solution.normalize("blue          is the sky"));
		
		assertEquals("blue is sky the", Solution.doReverseWords("the sky is blue"));
		assertEquals("fox brown big the", Solution.doReverseWords("the big brown fox"));
		assertEquals("fox brown big the", Solution.doReverseWords("the               big brown fox"));
		assertEquals("fox brown big the", Solution.doReverseWords(" the big brown fox"));
		assertEquals("fox brown big the", Solution.doReverseWords("the big brown fox           "));
		assertEquals("fox brown big the", Solution.doReverseWords(" the big              brown fox"));
		assertEquals("fox brown big", Solution.doReverseWords("big brown fox"));
		assertEquals("clown funny", Solution.doReverseWords("funny clown"));
		assertEquals("droog", Solution.doReverseWords("droog"));
		assertEquals("", Solution.doReverseWords("             "));
		assertEquals("", Solution.doReverseWords(" "));
		assertEquals("", Solution.doReverseWords(""));
	} 
}
